

import java.awt.GridBagLayout;
import java.util.Vector;

import javax.swing.ButtonGroup;
import javax.swing.JPanel;

public class Toolbox extends JPanel {
	private static final long serialVersionUID = 1L;
	private Vector<ChipButton> chips;  //  @jve:decl-index=0:
	private Workspace workspace;

	/**
	 * This is the default constructor
	 * @param p_workspace a handle to the workspace so the
	 * buttons we construct can know who to talk to.
	 */
	public Toolbox(Workspace p_workspace) {
		super();
		
		workspace = p_workspace;
		
		initialize();
	}

	/**
	 * This method initializes the toolbox's predefined chips
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(300, 200);
		this.setLayout(new GridBagLayout());
		chips = new Vector<ChipButton> ();
		ButtonGroup grp = new ButtonGroup();
		
		//Add AND gate
		ChipPin a = new ChipPin("a", null, null);
		ChipPin b = new ChipPin("b", null, null);
		ChipPin out = new ChipPin("out", null, null);
		Vector<ChipPin> inputs = new Vector<ChipPin>();
		Vector<ChipPin> outputs = new Vector<ChipPin>();
		inputs.add(a); inputs.add(b);
		outputs.add(out);
		
		Chip buildChip = new Chip("Images/ANDgate.png", inputs, outputs);
		ChipButton button = new ChipButton("Images/ANDgate.png", "Images/pANDgate.png", buildChip, workspace);
		grp.add(button);
		this.add(button);
		
		//TODO: Create a NAND gate
		//TODO: Create an OR gate
		//TODO: Create a NOR gate
		//TODO: Create an XOR gate
		//TODO: Create an XNOR gate
	}

}
